let fs = require('fs')
let fn = '1.txt'

//同步读取
let data = fs.readFileSync(fn)
console.log('同步读取文件内容 data:',data)


//同步写文件
fs.writeFileSync('2.txt',data.toString())
console.log('同步写到2.txt！')


//异步写入
fs.writeFile('3.txt',data.toString(),(err) => {
    if (err){
        console.log('异步写入失败！')
        return
    }
    console.log('异步写入成功！')
})
console.log('写入到3.txt')

//状态
let stat = fs.statSync('./1.txt')
console.log('stat:',stat)

//删除文件
fs.unlinkSync('3.txt')
